package com.ydc.controller;


import com.ydc.pojo.PageResult;
import com.ydc.pojo.Item;
import com.ydc.service.ItemService;
import com.ydc.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/item")
public class ItemController {

    @Autowired
    private ItemService itemService;



    @GetMapping("/getItemList")
    public SysResult findItemList(PageResult pageResult){
        pageResult = itemService.findItemList(pageResult);
        return SysResult.success(pageResult);
    }

    @PostMapping("/updateItem")
    public SysResult updateItem(@RequestBody Item item){
        itemService.updateItem(item);
        return SysResult.success();
    }


    @DeleteMapping("/deleteItemById/{id}")
    public SysResult deleteItem(@PathVariable Integer id){
        itemService.deleteItem(id);
        return  SysResult.success();
    }


    @PutMapping("/updateItemStatus")
    public SysResult updateRoomStatus(@RequestBody Item item){
        itemService.updateItemStatus(item);
        return SysResult.success();
    }

    @PostMapping("/addItem")
    public SysResult insertItem(@RequestBody Item item){
        itemService.insertItem(item);
        return  SysResult.success();
    }

}
